home *** CD-ROM | disk | FTP | other *** search
/ Champak 74 / Volume 74 My Disc - Damaged.iso / Games / shape_escape.swf / scripts / MochiAd.as < prev   
Text File  |  2008-08-07  |  33KB  |  997 lines

  1. package
  2. {
  3.    import flash.display.DisplayObjectContainer;
  4.    import flash.display.Loader;
  5.    import flash.display.MovieClip;
  6.    import flash.events.Event;
  7.    import flash.net.LocalConnection;
  8.    import flash.net.URLRequest;
  9.    import flash.net.URLRequestMethod;
  10.    import flash.net.URLVariables;
  11.    import flash.system.Security;
  12.    import flash.utils.getTimer;
  13.    import flash.utils.setTimeout;
  14.    
  15.    public class MochiAd
  16.    {
  17.        
  18.       
  19.       public function MochiAd()
  20.       {
  21.          super();
  22.       }
  23.       
  24.       public static function getVersion() : String
  25.       {
  26.          return "2.5";
  27.       }
  28.       
  29.       public static function showClickAwayAd(param1:Object) : void
  30.       {
  31.          var DEFAULTS:Object = null;
  32.          var clip:Object = null;
  33.          var ad_timeout:Number = NaN;
  34.          var mc:MovieClip = null;
  35.          var wh:Array = null;
  36.          var w:Number = NaN;
  37.          var h:Number = NaN;
  38.          var chk:MovieClip = null;
  39.          var sendHostProgress:Boolean = false;
  40.          var options:Object = param1;
  41.          DEFAULTS = {
  42.             "ad_timeout":2000,
  43.             "regpt":"o",
  44.             "method":"showClickAwayAd",
  45.             "res":"300x250",
  46.             "no_bg":true,
  47.             "ad_started":function():void
  48.             {
  49.             },
  50.             "ad_finished":function():void
  51.             {
  52.             },
  53.             "ad_loaded":function(param1:Number, param2:Number):void
  54.             {
  55.             },
  56.             "ad_failed":function():void
  57.             {
  58.                trace("[MochiAd] Couldn\'t load an ad, make sure your game\'s local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
  59.             },
  60.             "ad_skipped":function():void
  61.             {
  62.             }
  63.          };
  64.          options = MochiAd._parseOptions(options,DEFAULTS);
  65.          clip = options.clip;
  66.          ad_timeout = options.ad_timeout;
  67.          delete options.ad_timeout;
  68.          if(!MochiAd.load(options))
  69.          {
  70.             options.ad_failed();
  71.             options.ad_finished();
  72.             return;
  73.          }
  74.          options.ad_started();
  75.          mc = clip._mochiad;
  76.          mc["onUnload"] = function():void
  77.          {
  78.             MochiAd._cleanup(mc);
  79.             options.ad_finished();
  80.          };
  81.          wh = MochiAd._getRes(options,clip);
  82.          w = wh[0];
  83.          h = wh[1];
  84.          mc.x = w * 0.5;
  85.          mc.y = h * 0.5;
  86.          chk = createEmptyMovieClip(mc,"_mochiad_wait",3);
  87.          chk.ad_timeout = ad_timeout;
  88.          chk.started = getTimer();
  89.          chk.showing = false;
  90.          mc.unloadAd = function():void
  91.          {
  92.             MochiAd.unload(clip);
  93.          };
  94.          mc.adLoaded = options.ad_loaded;
  95.          mc.adSkipped = options.ad_skipped;
  96.          mc.rpc = function(param1:Number, param2:Object):void
  97.          {
  98.             MochiAd.rpc(clip,param1,param2);
  99.          };
  100.          sendHostProgress = false;
  101.          mc.regContLC = function(param1:String):void
  102.          {
  103.             mc._containerLCName = param1;
  104.          };
  105.          chk["onEnterFrame"] = function():void
  106.          {
  107.             var _loc1_:Object = null;
  108.             var _loc2_:Number = NaN;
  109.             var _loc3_:Boolean = false;
  110.             var _loc4_:Number = NaN;
  111.             if(!this.parent)
  112.             {
  113.                delete this.onEnterFrame;
  114.                return;
  115.             }
  116.             _loc1_ = this.parent._mochiad_ctr;
  117.             _loc2_ = getTimer() - this.started;
  118.             _loc3_ = false;
  119.             if(!chk.showing)
  120.             {
  121.                if((_loc4_ = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal) > 0)
  122.                {
  123.                   chk.showing = true;
  124.                   _loc3_ = true;
  125.                   chk.started = getTimer();
  126.                }
  127.                else if(_loc2_ > chk.ad_timeout)
  128.                {
  129.                   options.ad_failed();
  130.                   _loc3_ = true;
  131.                }
  132.             }
  133.             if(this.root == null)
  134.             {
  135.                _loc3_ = true;
  136.             }
  137.             if(_loc3_)
  138.             {
  139.                delete this.onEnterFrame;
  140.             }
  141.          };
  142.          doOnEnterFrame(chk);
  143.       }
  144.       
  145.       public static function _isNetworkAvailable() : Boolean
  146.       {
  147.          return Security.sandboxType != "localWithFile";
  148.       }
  149.       
  150.       public static function _allowDomains(param1:String) : String
  151.       {
  152.          var _loc2_:String = null;
  153.          _loc2_ = param1.split("/")[2].split(":")[0];
  154.          Security.allowDomain("*");
  155.          Security.allowDomain(_loc2_);
  156.          Security.allowInsecureDomain("*");
  157.          Security.allowInsecureDomain(_loc2_);
  158.          return _loc2_;
  159.       }
  160.       
  161.       public static function unload(param1:Object) : Boolean
  162.       {
  163.          if(param1.clip && param1.clip._mochiad)
  164.          {
  165.             param1 = param1.clip;
  166.          }
  167.          if(param1.origFrameRate != undefined)
  168.          {
  169.             param1.stage.frameRate = param1.origFrameRate;
  170.          }
  171.          if(!param1._mochiad)
  172.          {
  173.             return false;
  174.          }
  175.          if(param1._mochiad._containerLCName != undefined)
  176.          {
  177.             param1._mochiad.lc.send(param1._mochiad._containerLCName,"notify",{"id":"unload"});
  178.          }
  179.          if(param1._mochiad.onUnload)
  180.          {
  181.             param1._mochiad.onUnload();
  182.          }
  183.          delete param1._mochiad_loaded;
  184.          delete param1._mochiad;
  185.          return true;
  186.       }
  187.       
  188.       public static function showInterLevelAd(param1:Object) : void
  189.       {
  190.          var DEFAULTS:Object = null;
  191.          var clip:Object = null;
  192.          var ad_msec:Number = NaN;
  193.          var ad_timeout:Number = NaN;
  194.          var fadeout_time:Number = NaN;
  195.          var mc:MovieClip = null;
  196.          var wh:Array = null;
  197.          var w:Number = NaN;
  198.          var h:Number = NaN;
  199.          var chk:MovieClip = null;
  200.          var options:Object = param1;
  201.          DEFAULTS = {
  202.             "ad_timeout":2000,
  203.             "fadeout_time":250,
  204.             "regpt":"o",
  205.             "method":"showTimedAd",
  206.             "ad_started":function():void
  207.             {
  208.                if(this.clip is MovieClip)
  209.                {
  210.                   this.clip.stop();
  211.                   return;
  212.                }
  213.                throw new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.");
  214.             },
  215.             "ad_finished":function():void
  216.             {
  217.                if(this.clip is MovieClip)
  218.                {
  219.                   this.clip.play();
  220.                   return;
  221.                }
  222.                throw new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.");
  223.             },
  224.             "ad_loaded":function(param1:Number, param2:Number):void
  225.             {
  226.             },
  227.             "ad_failed":function():void
  228.             {
  229.                trace("[MochiAd] Couldn\'t load an ad, make sure your game\'s local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
  230.             },
  231.             "ad_skipped":function():void
  232.             {
  233.             }
  234.          };
  235.          options = MochiAd._parseOptions(options,DEFAULTS);
  236.          clip = options.clip;
  237.          ad_msec = 11000;
  238.          ad_timeout = options.ad_timeout;
  239.          delete options.ad_timeout;
  240.          fadeout_time = options.fadeout_time;
  241.          delete options.fadeout_time;
  242.          if(!MochiAd.load(options))
  243.          {
  244.             options.ad_failed();
  245.             options.ad_finished();
  246.             return;
  247.          }
  248.          options.ad_started();
  249.          mc = clip._mochiad;
  250.          mc["onUnload"] = function():void
  251.          {
  252.             MochiAd._cleanup(mc);
  253.             options.ad_finished();
  254.          };
  255.          wh = MochiAd._getRes(options,clip);
  256.          w = wh[0];
  257.          h = wh[1];
  258.          mc.x = w * 0.5;
  259.          mc.y = h * 0.5;
  260.          chk = createEmptyMovieClip(mc,"_mochiad_wait",3);
  261.          chk.ad_msec = ad_msec;
  262.          chk.ad_timeout = ad_timeout;
  263.          chk.started = getTimer();
  264.          chk.showing = false;
  265.          chk.fadeout_time = fadeout_time;
  266.          chk.fadeFunction = function():void
  267.          {
  268.             var _loc1_:Number = NaN;
  269.             if(!this.parent)
  270.             {
  271.                delete this.onEnterFrame;
  272.                delete this.fadeFunction;
  273.                return;
  274.             }
  275.             _loc1_ = 100 * (1 - (getTimer() - this.fadeout_start) / this.fadeout_time);
  276.             if(_loc1_ > 0)
  277.             {
  278.                this.parent.alpha = _loc1_ * 0.01;
  279.             }
  280.             else
  281.             {
  282.                MochiAd.unload(clip);
  283.                delete this["onEnterFrame"];
  284.             }
  285.          };
  286.          mc.unloadAd = function():void
  287.          {
  288.             MochiAd.unload(clip);
  289.          };
  290.          mc.adLoaded = options.ad_loaded;
  291.          mc.adSkipped = options.ad_skipped;
  292.          mc.adjustProgress = function(param1:Number):void
  293.          {
  294.             var _loc2_:Object = null;
  295.             _loc2_ = mc._mochiad_wait;
  296.             _loc2_.server_control = true;
  297.             _loc2_.showing = true;
  298.             _loc2_.started = getTimer();
  299.             _loc2_.ad_msec = param1 - 250;
  300.          };
  301.          mc.rpc = function(param1:Number, param2:Object):void
  302.          {
  303.             MochiAd.rpc(clip,param1,param2);
  304.          };
  305.          chk["onEnterFrame"] = function():void
  306.          {
  307.             var _loc1_:Object = null;
  308.             var _loc2_:Number = NaN;
  309.             var _loc3_:Boolean = false;
  310.             var _loc4_:Number = NaN;
  311.             if(!this.parent)
  312.             {
  313.                delete this.onEnterFrame;
  314.                delete this.fadeFunction;
  315.                return;
  316.             }
  317.             _loc1_ = this.parent._mochiad_ctr;
  318.             _loc2_ = getTimer() - this.started;
  319.             _loc3_ = false;
  320.             if(!chk.showing)
  321.             {
  322.                if((_loc4_ = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal) > 0)
  323.                {
  324.                   chk.showing = true;
  325.                   chk.started = getTimer();
  326.                   MochiAd.adShowing(clip);
  327.                }
  328.                else if(_loc2_ > chk.ad_timeout)
  329.                {
  330.                   options.ad_failed();
  331.                   _loc3_ = true;
  332.                }
  333.             }
  334.             if(_loc2_ > chk.ad_msec)
  335.             {
  336.                _loc3_ = true;
  337.             }
  338.             if(_loc3_)
  339.             {
  340.                if(this.server_control)
  341.                {
  342.                   delete this.onEnterFrame;
  343.                }
  344.                else
  345.                {
  346.                   this.fadeout_start = getTimer();
  347.                   this.onEnterFrame = this.fadeFunction;
  348.                }
  349.             }
  350.          };
  351.          doOnEnterFrame(chk);
  352.       }
  353.       
  354.       public static function _parseOptions(param1:Object, param2:Object) : Object
  355.       {
  356.          var _loc3_:Object = null;
  357.          var _loc4_:* = null;
  358.          var _loc5_:Array = null;
  359.          var _loc6_:Number = NaN;
  360.          var _loc7_:Array = null;
  361.          _loc3_ = {};
  362.          for(_loc4_ in param2)
  363.          {
  364.             _loc3_[_loc4_] = param2[_loc4_];
  365.          }
  366.          if(param1)
  367.          {
  368.             for(_loc4_ in param1)
  369.             {
  370.                _loc3_[_loc4_] = param1[_loc4_];
  371.             }
  372.          }
  373.          if(_loc3_.clip == undefined)
  374.          {
  375.             throw new Error("MochiAd is missing the \'clip\' parameter.  This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite.");
  376.          }
  377.          param1 = _loc3_.clip.loaderInfo.parameters.mochiad_options;
  378.          if(param1)
  379.          {
  380.             _loc5_ = param1.split("&");
  381.             _loc6_ = 0;
  382.             while(_loc6_ < _loc5_.length)
  383.             {
  384.                _loc7_ = _loc5_[_loc6_].split("=");
  385.                _loc3_[unescape(_loc7_[0])] = unescape(_loc7_[1]);
  386.                _loc6_++;
  387.             }
  388.          }
  389.          if(_loc3_.id == "test")
  390.          {
  391.             trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
  392.          }
  393.          return _loc3_;
  394.       }
  395.       
  396.       public static function _cleanup(param1:Object) : void
  397.       {
  398.          var idx:Number = NaN;
  399.          var k:String = null;
  400.          var lc:LocalConnection = null;
  401.          var f:Function = null;
  402.          var mc:Object = param1;
  403.          if("lc" in mc)
  404.          {
  405.             lc = mc.lc;
  406.             f = function():void
  407.             {
  408.                try
  409.                {
  410.                   lc.client = null;
  411.                   lc.close();
  412.                }
  413.                catch(e:Error)
  414.                {
  415.                }
  416.             };
  417.             setTimeout(f,0);
  418.          }
  419.          idx = DisplayObjectContainer(mc).numChildren;
  420.          while(idx > 0)
  421.          {
  422.             idx--;
  423.             DisplayObjectContainer(mc).removeChildAt(idx);
  424.          }
  425.          for(k in mc)
  426.          {
  427.             delete mc[k];
  428.          }
  429.       }
  430.       
  431.       public static function load(param1:Object) : MovieClip
  432.       {
  433.          var DEFAULTS:Object = null;
  434.          var clip:Object = null;
  435.          var depth:Number = NaN;
  436.          var mc:MovieClip = null;
  437.          var wh:Array = null;
  438.          var lv:URLVariables = null;
  439.          var k:String = null;
  440.          var server:String = null;
  441.          var hostname:String = null;
  442.          var lc:LocalConnection = null;
  443.          var name:String = null;
  444.          var loader:Loader = null;
  445.          var g:Function = null;
  446.          var req:URLRequest = null;
  447.          var v:Object = null;
  448.          var options:Object = param1;
  449.          DEFAULTS = {
  450.             "server":"http://x.mochiads.com/srv/1/",
  451.             "method":"load",
  452.             "depth":10333,
  453.             "id":"_UNKNOWN_"
  454.          };
  455.          options = MochiAd._parseOptions(options,DEFAULTS);
  456.          options.swfv = 9;
  457.          options.mav = MochiAd.getVersion();
  458.          clip = options.clip;
  459.          if(!MochiAd._isNetworkAvailable())
  460.          {
  461.             return null;
  462.          }
  463.          try
  464.          {
  465.             if(clip._mochiad_loaded)
  466.             {
  467.                return null;
  468.             }
  469.          }
  470.          catch(e:Error)
  471.          {
  472.             throw new Error("MochiAd requires a clip that is an instance of a dynamic class.  If your class extends Sprite or MovieClip, you must make it dynamic.");
  473.          }
  474.          depth = options.depth;
  475.          delete options.depth;
  476.          mc = createEmptyMovieClip(clip,"_mochiad",depth);
  477.          wh = MochiAd._getRes(options,clip);
  478.          options.res = wh[0] + "x" + wh[1];
  479.          options.server += options.id;
  480.          delete options.id;
  481.          clip._mochiad_loaded = true;
  482.          if(clip.loaderInfo.loaderURL.indexOf("http") == 0)
  483.          {
  484.             options.as3_swf = clip.loaderInfo.loaderURL;
  485.          }
  486.          lv = new URLVariables();
  487.          for(k in options)
  488.          {
  489.             v = options[k];
  490.             if(!(v is Function))
  491.             {
  492.                lv[k] = v;
  493.             }
  494.          }
  495.          server = lv.server;
  496.          delete lv.server;
  497.          hostname = _allowDomains(server);
  498.          lc = new LocalConnection();
  499.          lc.client = mc;
  500.          name = ["",Math.floor(new Date().getTime()),Math.floor(Math.random() * 999999)].join("_");
  501.          lc.allowDomain("*","localhost");
  502.          lc.allowInsecureDomain("*","localhost");
  503.          lc.connect(name);
  504.          mc.lc = lc;
  505.          mc.lcName = name;
  506.          lv.lc = name;
  507.          lv.st = getTimer();
  508.          loader = new Loader();
  509.          g = function(param1:Object):void
  510.          {
  511.             param1.target.removeEventListener(param1.type,arguments.callee);
  512.             MochiAd.unload(clip);
  513.          };
  514.          loader.contentLoaderInfo.addEventListener(Event.UNLOAD,g);
  515.          req = new URLRequest(server + ".swf");
  516.          req.contentType = "application/x-www-form-urlencoded";
  517.          req.method = URLRequestMethod.POST;
  518.          req.data = lv;
  519.          loader.load(req);
  520.          mc.addChild(loader);
  521.          mc._mochiad_ctr = loader;
  522.          return mc;
  523.       }
  524.       
  525.       public static function runMethod(param1:Object, param2:String, param3:Array) : Object
  526.       {
  527.          var _loc4_:Array = null;
  528.          var _loc5_:Number = NaN;
  529.          _loc4_ = param2.split(".");
  530.          _loc5_ = 0;
  531.          while(_loc5_ < _loc4_.length - 1)
  532.          {
  533.             if(param1[_loc4_[_loc5_]] == undefined || param1[_loc4_[_loc5_]] == null)
  534.             {
  535.                return undefined;
  536.             }
  537.             param1 = param1[_loc4_[_loc5_]];
  538.             _loc5_++;
  539.          }
  540.          if(typeof param1[_loc4_[_loc5_]] == "function")
  541.          {
  542.             return param1[_loc4_[_loc5_]].apply(param1,param3);
  543.          }
  544.          return undefined;
  545.       }
  546.       
  547.       public static function createEmptyMovieClip(param1:Object, param2:String, param3:Number) : MovieClip
  548.       {
  549.          var _loc4_:MovieClip = null;
  550.          _loc4_ = new MovieClip();
  551.          if(false && param3)
  552.          {
  553.             param1.addChildAt(_loc4_,param3);
  554.          }
  555.          else
  556.          {
  557.             param1.addChild(_loc4_);
  558.          }
  559.          param1[param2] = _loc4_;
  560.          _loc4_["_name"] = param2;
  561.          return _loc4_;
  562.       }
  563.       
  564.       public static function _getRes(param1:Object, param2:Object) : Array
  565.       {
  566.          var _loc3_:Object = null;
  567.          var _loc4_:Number = NaN;
  568.          var _loc5_:Number = NaN;
  569.          var _loc6_:Array = null;
  570.          _loc3_ = param2.getBounds(param2.root);
  571.          _loc4_ = 0;
  572.          _loc5_ = 0;
  573.          if(typeof param1.res != "undefined")
  574.          {
  575.             _loc6_ = param1.res.split("x");
  576.             _loc4_ = parseFloat(_loc6_[0]);
  577.             _loc5_ = parseFloat(_loc6_[1]);
  578.          }
  579.          else
  580.          {
  581.             _loc4_ = _loc3_.xMax - _loc3_.xMin;
  582.             _loc5_ = _loc3_.yMax - _loc3_.yMin;
  583.          }
  584.          if(_loc4_ == 0 || _loc5_ == 0)
  585.          {
  586.             _loc4_ = param2.stage.stageWidth;
  587.             _loc5_ = param2.stage.stageHeight;
  588.          }
  589.          return [_loc4_,_loc5_];
  590.       }
  591.       
  592.       public static function adShowing(param1:Object) : void
  593.       {
  594.          param1.origFrameRate = param1.stage.frameRate;
  595.          param1.stage.frameRate = 30;
  596.       }
  597.       
  598.       public static function getValue(param1:Object, param2:String) : Object
  599.       {
  600.          var _loc3_:Array = null;
  601.          var _loc4_:Number = NaN;
  602.          _loc3_ = param2.split(".");
  603.          _loc4_ = 0;
  604.          while(_loc4_ < _loc3_.length - 1)
  605.          {
  606.             if(param1[_loc3_[_loc4_]] == undefined || param1[_loc3_[_loc4_]] == null)
  607.             {
  608.                return undefined;
  609.             }
  610.             param1 = param1[_loc3_[_loc4_]];
  611.             _loc4_++;
  612.          }
  613.          return param1[_loc3_[_loc4_]];
  614.       }
  615.       
  616.       public static function rpc(param1:Object, param2:Number, param3:Object) : void
  617.       {
  618.          var _loc4_:Object = null;
  619.          var _loc5_:Object = null;
  620.          switch(param3.id)
  621.          {
  622.             case "setValue":
  623.                MochiAd.setValue(param1,param3.objectName,param3.value);
  624.                break;
  625.             case "getValue":
  626.                _loc4_ = MochiAd.getValue(param1,param3.objectName);
  627.                param1._mochiad.lc.send(param1._mochiad._containerLCName,"rpcResult",param2,_loc4_);
  628.                break;
  629.             case "runMethod":
  630.                _loc5_ = MochiAd.runMethod(param1,param3.method,param3.args);
  631.                param1._mochiad.lc.send(param1._mochiad._containerLCName,"rpcResult",param2,_loc5_);
  632.                break;
  633.             default:
  634.                trace("[mochiads rpc] unknown rpc id: " + param3.id);
  635.          }
  636.       }
  637.       
  638.       public static function setValue(param1:Object, param2:String, param3:Object) : void
  639.       {
  640.          var _loc4_:Array = null;
  641.          var _loc5_:Number = NaN;
  642.          _loc4_ = param2.split(".");
  643.          _loc5_ = 0;
  644.          while(_loc5_ < _loc4_.length - 1)
  645.          {
  646.             if(param1[_loc4_[_loc5_]] == undefined || param1[_loc4_[_loc5_]] == null)
  647.             {
  648.                return;
  649.             }
  650.             param1 = param1[_loc4_[_loc5_]];
  651.             _loc5_++;
  652.          }
  653.          param1[_loc4_[_loc5_]] = param3;
  654.       }
  655.       
  656.       public static function showPreGameAd(param1:Object) : void
  657.       {
  658.          var DEFAULTS:Object = null;
  659.          var clip:Object = null;
  660.          var ad_msec:Number = NaN;
  661.          var ad_timeout:Number = NaN;
  662.          var fadeout_time:Number = NaN;
  663.          var mc:MovieClip = null;
  664.          var wh:Array = null;
  665.          var w:Number = NaN;
  666.          var h:Number = NaN;
  667.          var chk:MovieClip = null;
  668.          var bar:MovieClip = null;
  669.          var bar_color:Number = NaN;
  670.          var bar_background:Number = NaN;
  671.          var bar_outline:Number = NaN;
  672.          var backing_mc:MovieClip = null;
  673.          var backing:Object = null;
  674.          var inside_mc:MovieClip = null;
  675.          var inside:Object = null;
  676.          var outline_mc:MovieClip = null;
  677.          var outline:Object = null;
  678.          var complete:Boolean = false;
  679.          var unloaded:Boolean = false;
  680.          var f:Function = null;
  681.          var sendHostProgress:Boolean = false;
  682.          var r:MovieClip = null;
  683.          var options:Object = param1;
  684.          DEFAULTS = {
  685.             "ad_timeout":3000,
  686.             "fadeout_time":250,
  687.             "regpt":"o",
  688.             "method":"showPreloaderAd",
  689.             "color":16747008,
  690.             "background":16777161,
  691.             "outline":13994812,
  692.             "no_progress_bar":false,
  693.             "ad_started":function():void
  694.             {
  695.                if(this.clip is MovieClip)
  696.                {
  697.                   this.clip.stop();
  698.                   return;
  699.                }
  700.                throw new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.");
  701.             },
  702.             "ad_finished":function():void
  703.             {
  704.                if(this.clip is MovieClip)
  705.                {
  706.                   this.clip.play();
  707.                   return;
  708.                }
  709.                throw new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.");
  710.             },
  711.             "ad_loaded":function(param1:Number, param2:Number):void
  712.             {
  713.             },
  714.             "ad_failed":function():void
  715.             {
  716.                trace("[MochiAd] Couldn\'t load an ad, make sure your game\'s local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
  717.             },
  718.             "ad_skipped":function():void
  719.             {
  720.             },
  721.             "ad_progress":function(param1:Number):void
  722.             {
  723.             }
  724.          };
  725.          options = MochiAd._parseOptions(options,DEFAULTS);
  726.          if("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def")
  727.          {
  728.             options.ad_started();
  729.             setTimeout(options.ad_finished,100);
  730.             return;
  731.          }
  732.          clip = options.clip;
  733.          ad_msec = 11000;
  734.          ad_timeout = options.ad_timeout;
  735.          delete options.ad_timeout;
  736.          fadeout_time = options.fadeout_time;
  737.          delete options.fadeout_time;
  738.          if(!MochiAd.load(options))
  739.          {
  740.             options.ad_failed();
  741.             options.ad_finished();
  742.             return;
  743.          }
  744.          options.ad_started();
  745.          mc = clip._mochiad;
  746.          mc["onUnload"] = function():void
  747.          {
  748.             var fn:Function = null;
  749.             MochiAd._cleanup(mc);
  750.             fn = function():void
  751.             {
  752.                options.ad_finished();
  753.             };
  754.             setTimeout(fn,100);
  755.          };
  756.          wh = MochiAd._getRes(options,clip);
  757.          w = wh[0];
  758.          h = wh[1];
  759.          mc.x = w * 0.5;
  760.          mc.y = h * 0.5;
  761.          chk = createEmptyMovieClip(mc,"_mochiad_wait",3);
  762.          chk.x = w * -0.5;
  763.          chk.y = h * -0.5;
  764.          bar = createEmptyMovieClip(chk,"_mochiad_bar",4);
  765.          if(options.no_progress_bar)
  766.          {
  767.             bar.visible = false;
  768.             delete options.no_progress_bar;
  769.          }
  770.          else
  771.          {
  772.             bar.x = 10;
  773.             bar.y = h - 20;
  774.          }
  775.          bar_color = options.color;
  776.          delete options.color;
  777.          bar_background = options.background;
  778.          delete options.background;
  779.          bar_outline = options.outline;
  780.          delete options.outline;
  781.          backing_mc = createEmptyMovieClip(bar,"_outline",1);
  782.          backing = backing_mc.graphics;
  783.          backing.beginFill(bar_background);
  784.          backing.moveTo(0,0);
  785.          backing.lineTo(w - 20,0);
  786.          backing.lineTo(w - 20,10);
  787.          backing.lineTo(0,10);
  788.          backing.lineTo(0,0);
  789.          backing.endFill();
  790.          inside_mc = createEmptyMovieClip(bar,"_inside",2);
  791.          inside = inside_mc.graphics;
  792.          inside.beginFill(bar_color);
  793.          inside.moveTo(0,0);
  794.          inside.lineTo(w - 20,0);
  795.          inside.lineTo(w - 20,10);
  796.          inside.lineTo(0,10);
  797.          inside.lineTo(0,0);
  798.          inside.endFill();
  799.          inside_mc.scaleX = 0;
  800.          outline_mc = createEmptyMovieClip(bar,"_outline",3);
  801.          outline = outline_mc.graphics;
  802.          outline.lineStyle(0,bar_outline,100);
  803.          outline.moveTo(0,0);
  804.          outline.lineTo(w - 20,0);
  805.          outline.lineTo(w - 20,10);
  806.          outline.lineTo(0,10);
  807.          outline.lineTo(0,0);
  808.          chk.ad_msec = ad_msec;
  809.          chk.ad_timeout = ad_timeout;
  810.          chk.started = getTimer();
  811.          chk.showing = false;
  812.          chk.last_pcnt = 0;
  813.          chk.fadeout_time = fadeout_time;
  814.          chk.fadeFunction = function():void
  815.          {
  816.             var _loc1_:Number = NaN;
  817.             _loc1_ = 100 * (1 - (getTimer() - this.fadeout_start) / this.fadeout_time);
  818.             if(_loc1_ > 0)
  819.             {
  820.                this.parent.alpha = _loc1_ * 0.01;
  821.             }
  822.             else
  823.             {
  824.                MochiAd.unload(clip);
  825.                delete this["onEnterFrame"];
  826.             }
  827.          };
  828.          complete = false;
  829.          unloaded = false;
  830.          f = function(param1:Event):void
  831.          {
  832.             param1.target.removeEventListener(param1.type,arguments.callee);
  833.             complete = true;
  834.             if(unloaded)
  835.             {
  836.                MochiAd.unload(clip);
  837.             }
  838.          };
  839.          clip.loaderInfo.addEventListener(Event.COMPLETE,f);
  840.          if(clip.root is MovieClip)
  841.          {
  842.             r = clip.root as MovieClip;
  843.             if(r.framesLoaded >= r.totalFrames)
  844.             {
  845.                complete = true;
  846.             }
  847.          }
  848.          mc.unloadAd = function():void
  849.          {
  850.             unloaded = true;
  851.             if(complete)
  852.             {
  853.                MochiAd.unload(clip);
  854.             }
  855.          };
  856.          mc.adLoaded = options.ad_loaded;
  857.          mc.adSkipped = options.ad_skipped;
  858.          mc.adjustProgress = function(param1:Number):void
  859.          {
  860.             var _loc2_:Object = null;
  861.             _loc2_ = mc._mochiad_wait;
  862.             _loc2_.server_control = true;
  863.             _loc2_.showing = true;
  864.             _loc2_.started = getTimer();
  865.             _loc2_.ad_msec = param1;
  866.          };
  867.          mc.rpc = function(param1:Number, param2:Object):void
  868.          {
  869.             MochiAd.rpc(clip,param1,param2);
  870.          };
  871.          mc.rpcTestFn = function(param1:String):Object
  872.          {
  873.             trace("[MOCHIAD rpcTestFn] " + param1);
  874.             return param1;
  875.          };
  876.          mc.regContLC = function(param1:String):void
  877.          {
  878.             mc._containerLCName = param1;
  879.          };
  880.          sendHostProgress = false;
  881.          mc.sendHostLoadProgress = function(param1:String):void
  882.          {
  883.             sendHostProgress = true;
  884.          };
  885.          chk["onEnterFrame"] = function():void
  886.          {
  887.             var _loc1_:Object = null;
  888.             var _loc2_:Object = null;
  889.             var _loc3_:Number = NaN;
  890.             var _loc4_:Boolean = false;
  891.             var _loc5_:Number = NaN;
  892.             var _loc6_:Number = NaN;
  893.             var _loc7_:Number = NaN;
  894.             var _loc8_:Number = NaN;
  895.             var _loc9_:Object = null;
  896.             var _loc10_:Number = NaN;
  897.             var _loc11_:Number = NaN;
  898.             if(!this.parent || !this.parent.parent)
  899.             {
  900.                delete this["onEnterFrame"];
  901.                return;
  902.             }
  903.             _loc1_ = this.parent.parent.root;
  904.             _loc2_ = this.parent._mochiad_ctr;
  905.             _loc3_ = getTimer() - this.started;
  906.             _loc4_ = false;
  907.             _loc5_ = _loc1_.loaderInfo.bytesTotal;
  908.             _loc6_ = _loc1_.loaderInfo.bytesLoaded;
  909.             if(complete)
  910.             {
  911.                _loc5_ = _loc6_ = Math.max(1,_loc6_);
  912.             }
  913.             _loc7_ = 100 * _loc6_ / _loc5_;
  914.             _loc8_ = 100 * _loc3_ / chk.ad_msec;
  915.             _loc9_ = this._mochiad_bar._inside;
  916.             _loc10_ = Math.min(100,Math.min(Number(_loc7_) || Number(0),_loc8_));
  917.             _loc10_ = Math.max(this.last_pcnt,_loc10_);
  918.             this.last_pcnt = _loc10_;
  919.             _loc9_.scaleX = _loc10_ * 0.01;
  920.             options.ad_progress(_loc10_);
  921.             if(sendHostProgress)
  922.             {
  923.                clip._mochiad.lc.send(clip._mochiad._containerLCName,"notify",{
  924.                   "id":"hostLoadPcnt",
  925.                   "pcnt":_loc7_
  926.                });
  927.                if(_loc7_ == 100)
  928.                {
  929.                   sendHostProgress = false;
  930.                }
  931.             }
  932.             if(!chk.showing)
  933.             {
  934.                if((_loc11_ = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal) > 0)
  935.                {
  936.                   chk.showing = true;
  937.                   chk.started = getTimer();
  938.                   MochiAd.adShowing(clip);
  939.                }
  940.                else if(_loc3_ > chk.ad_timeout && _loc7_ == 100)
  941.                {
  942.                   options.ad_failed();
  943.                   _loc4_ = true;
  944.                }
  945.             }
  946.             if(_loc3_ > chk.ad_msec)
  947.             {
  948.                _loc4_ = true;
  949.             }
  950.             if(complete && _loc4_)
  951.             {
  952.                if(this.server_control)
  953.                {
  954.                   delete this.onEnterFrame;
  955.                }
  956.                else
  957.                {
  958.                   this.fadeout_start = getTimer();
  959.                   this.onEnterFrame = chk.fadeFunction;
  960.                }
  961.             }
  962.          };
  963.          doOnEnterFrame(chk);
  964.       }
  965.       
  966.       public static function showPreloaderAd(param1:Object) : void
  967.       {
  968.          trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
  969.          MochiAd.showPreGameAd(param1);
  970.       }
  971.       
  972.       public static function showTimedAd(param1:Object) : void
  973.       {
  974.          trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
  975.          MochiAd.showInterLevelAd(param1);
  976.       }
  977.       
  978.       public static function doOnEnterFrame(param1:MovieClip) : void
  979.       {
  980.          var f:Function = null;
  981.          var mc:MovieClip = param1;
  982.          f = function(param1:Object):void
  983.          {
  984.             if("onEnterFrame" in mc && mc.onEnterFrame)
  985.             {
  986.                mc.onEnterFrame();
  987.             }
  988.             else
  989.             {
  990.                param1.target.removeEventListener(param1.type,arguments.callee);
  991.             }
  992.          };
  993.          mc.addEventListener(Event.ENTER_FRAME,f);
  994.       }
  995.    }
  996. }
  997.